package main

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/dialog"
	"fyne.io/fyne/v2/widget"
)

func main() {
	a := app.New()                   //创建应用
	w := a.NewWindow("学习")           //创建窗口 窗口名称是学习
	w.Resize(fyne.NewSize(320, 170)) //设置窗口大小
	w.CenterOnScreen()               //把窗口设置到屏幕中央
	c := container.NewWithoutLayout()
	//名称标签
	lname := widget.NewLabel("姓名：")
	lname.Alignment = fyne.TextAlignLeading
	lname.Resize(fyne.NewSize(50, 30))
	lname.Move(fyne.NewPos(10, 10))
	//名称输入框
	nameEntry := widget.NewEntry()
	nameEntry.Resize(fyne.NewSize(200, 40))
	nameEntry.Move(fyne.NewPos(70, 10))
	//密码标签
	lpass := widget.NewLabel("密码：")
	lpass.Alignment = fyne.TextAlignLeading
	lpass.Resize(fyne.NewSize(50, 30))
	lpass.Move(fyne.NewPos(10, 60))
	//密码输入框
	passEntry := widget.NewPasswordEntry()
	passEntry.Resize(fyne.NewSize(200, 40))
	passEntry.Move(fyne.NewPos(70, 60))
	//按钮
	btn := widget.NewButton("登录", func() {
		dialog.ShowInformation("登录成功", "你的名字是"+nameEntry.Text, w)
	})
	btn.Resize(fyne.NewSize(100, 30))
	btn.Move(fyne.NewPos(100, 120))
	c.Add(lname)
	c.Add(nameEntry)
	c.Add(lpass)
	c.Add(passEntry)
	c.Add(btn)
	w.SetContent(c)
	w.ShowAndRun() ///显示窗口并运行
}
